{extend name="base" /}
{block name="content"}
<div class="iframe_div layui-anim layui-anim-upbit">
    <div class="top_btn_tool">
        {if power('column_create','创建商品分类','column')}
        <button class="layui-btn" data-type="create_btn">新增</button>
        {/if}
    </div>
    <div class="clear link_15"></div>

    <div class="table_div">
        <table class="layui-hide" id="table_list" lay-filter="table_list"></table>
    </div>
</div>
{/block}
{block name="script"}
<script>
    layui.config({
        base: '<?php echo SITE;?>static/layuiadmin/'
    }).extend({
        index: 'lib/index'
    }).use(['index'],async () => {
        const { layer,form, admin, table, $,element,upload } = layui;

        /*渲染表格*/
        let table_list = table.render({
            elem: '#table_list'
            ,url:'column_list'
            ,page:true
            ,limit:15
            ,cols: [[
                {field:'id', width:80, title: 'ID'}
                ,{field:'name', title: '名称'}
                ,{field:'parent',width:120, title: '所属'}
                ,{toolbar: '#barDemo',width:140, title: '操作'}
            ]]
        });



        /*监听表格动作*/
        table.on('tool(table_list)', function(obj){
            let data = obj.data;
            if(obj.event === 'del'){
                layer.confirm('真的删除行么',async function(index){
                    let res = await admin.delete('/plugin/shop/'+data.id);
                    if(res.status){
                        obj.del();
                        layer.close(index);
                    }
                });
            } else if(obj.event === 'edit'){
                clean_data(data);
                layer.open({
                    type: 1
                    , title: '编辑'
                    , area: ['400px']
                    , maxmin: true
                    , shade: 0.6
                    , content: $('#create_op')
                });
            }
        });
    });
</script>
{/block}

{block name="template"}
{include file="shop/column/template" /}
{/block}